import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/query_entity.dart';

QueryEntity $QueryEntityFromJson(Map<String, dynamic> json) {
  final QueryEntity queryEntity = QueryEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    queryEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    queryEntity.msg = msg;
  }
  final List<QueryData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<QueryData>(e) as QueryData).toList();
  if (data != null) {
    queryEntity.data = data;
  }
  return queryEntity;
}

Map<String, dynamic> $QueryEntityToJson(QueryEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension QueryEntityExtension on QueryEntity {
  QueryEntity copyWith({
    int? code,
    String? msg,
    List<QueryData>? data,
  }) {
    return QueryEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

QueryData $QueryDataFromJson(Map<String, dynamic> json) {
  final QueryData queryData = QueryData();
  final int? isSelf = jsonConvert.convert<int>(json['is_self']);
  if (isSelf != null) {
    queryData.isSelf = isSelf;
  }
  final String? imgUrl = jsonConvert.convert<String>(json['img_url']);
  if (imgUrl != null) {
    queryData.imgUrl = imgUrl;
  }
  final String? addTime = jsonConvert.convert<String>(json['add_time']);
  if (addTime != null) {
    queryData.addTime = addTime;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    queryData.title = title;
  }
  final String? categoryText = jsonConvert.convert<String>(
      json['category_text']);
  if (categoryText != null) {
    queryData.categoryText = categoryText;
  }
  final String? sellPrice = jsonConvert.convert<String>(json['sell_price']);
  if (sellPrice != null) {
    queryData.sellPrice = sellPrice;
  }
  return queryData;
}

Map<String, dynamic> $QueryDataToJson(QueryData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['is_self'] = entity.isSelf;
  data['img_url'] = entity.imgUrl;
  data['add_time'] = entity.addTime;
  data['title'] = entity.title;
  data['category_text'] = entity.categoryText;
  data['sell_price'] = entity.sellPrice;
  return data;
}

extension QueryDataExtension on QueryData {
  QueryData copyWith({
    int? isSelf,
    String? imgUrl,
    String? addTime,
    String? title,
    String? categoryText,
    String? sellPrice,
  }) {
    return QueryData()
      ..isSelf = isSelf ?? this.isSelf
      ..imgUrl = imgUrl ?? this.imgUrl
      ..addTime = addTime ?? this.addTime
      ..title = title ?? this.title
      ..categoryText = categoryText ?? this.categoryText
      ..sellPrice = sellPrice ?? this.sellPrice;
  }
}